package banking;

import banking.domain.OverdraftException;

public class Account {
    protected double balance;


    public Account() {
        this(0);
    }

    public Account(double init_balance){
        this.balance = init_balance;
    }


    public double getBalance() {
        return balance;
    }

    public boolean deposit(double balance){
        this.balance += balance;
        return true;
    }

    public void withdraw(double balance) throws OverdraftException {
        if (this.balance > balance){
            this.balance -= balance;
        }else{
            throw new OverdraftException("资金不足", this.balance);
        }
    }


}


